﻿package net.imonair.msn.utils {	
	import flash.text.TextFormatAlign;
	import flash.text.TextFormat;
	/**
	 * Function used for internal TextFormat conversion.
	 * @param string A string to be unserialized
	 * @return A TextFormat instance
	 * @see flash.text.TextFormat
	 */
	public function unSerializeTextFormat(string:String):TextFormat {
		string = unescape(string);
		var data:Object = {};
		for each (var code:String in string.split("; ")) {
			var temp:Array = code.split("=");
			data[temp[0]] = temp[1];
		}
		var color:String = data["CO"];
		while (color.length != 6) color = "0" + color;
		color = "0x" + color.substr(4, 2) + color.substr(2, 2) + color.substr(0, 2);
		//EF=BIUS
		//CS=?
		//PF=?
		var textFormat:TextFormat = new TextFormat(data["FN"], null, color, "B", "I", "U", null, null, data["RL"] == "1"? TextFormatAlign.LEFT : TextFormatAlign.RIGHT);
		return textFormat;
	}
}